home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
lisp
/
eulisp
/
mpfeel.lha
/
MPFeel
/
Plurals
/
MP_PluralHeap.h
< prev
next >
Wrap
Text File
|
1992-01-30
|
5KB
|
132 lines
/*
* Plurals
*
* Author: S.C.Merrall
*
* File: MP_PluralHeap.c
*
* Contents:
*
* Description: This object gives a better handle on the content of the
* heap space. At this time I see no need to create
* anything other than dynamic instances of this class
* so none of the supporting code is present
*
* Change History:
*
* Date Name Comment
* -------- ---- -------
* 19:04:91 SCM Created
* 22:04:91 SCM Offset now offsets, pointer to plural of naturals
* 27:05:91 SCM MP_PluralHeap no longer a true object
* 04:06:91 SCM Converted header to 16 bits
* 29:01:92 SCM Added macros for storing forwarding addresses in headers
*
*/
/* At this moment I am loathe to start creating pplural instances of
* objects or plural objects. Ideally I would have singular objects with
* plural things inside them. I can't do this without initialisation
* code. This would mean I would no longer be able to create them on the
* stck. So I will discard them as objects and resort to the folloeing
* typedef.
*/
typedef plural natural *plural MP_PluralHeap;
/* typedef int heap_header;
*
* #define HH_FREE 0x8000
* #define HH_INFO 0x7FFF
* #define HH_SPACE 0xFFFF0000
*
* #define HH_space(HEADER) (HEADER >> 16)
* #define HH_free(HEADER) ((HEADER & HH_FREE) == H_FREE)
* #define HH_info(HEADER) (HEADER & HH_INFO)
* #define HH_set_space(HEADER,VALUE) (HEADER = (VALUE << 16) | \
* (HEADER & ~HH_SPACE))
* #define HH_set_free(HEADER,VALUE) (HEADER = HEADER | (VALUE << 15))
* #define HH_set_info(HEADER,VALUE) (HEADER = (VALUE | (HEADER & ~HH_INFO)))
*
*/
typedef natural heap_header;
/* #define HH_FREE 0x0010
* #define HH_INFO 0x000F
* #define HH_SPACE 0xFFE0
*
* #define HH_space(HEADER) (HEADER >> 5)
* #define HH_free(HEADER) ((HEADER & HH_FREE) == H_FREE)
* #define HH_info(HEADER) (HEADER & HH_INFO)
* #define HH_set_space(HEADER,VALUE) (HEADER = (VALUE << 5) | \
* (HEADER & ~HH_SPACE))
* #define HH_set_free(HEADER,VALUE) (HEADER = HEADER | (VALUE << 4))
* #define HH_set_info(HEADER,VALUE) (HEADER = (VALUE | (HEADER & ~HH_INFO)))
*/
/* In this version, free and info have been swapped around. Thus if it is free there is
* a 15-bit space we can store the forwarding address in!
*/
#define HH_FREE 0x0001
#define HH_GCTO 0xFFFE
#define HH_INFO 0x001E
#define HH_SPACE 0xFFE0
#define HH_space(HEADER) (HEADER >> 5)
#define HH_gcto(HEADER) (HEADER >> 1)
#define HH_free(HEADER) (HEADER & HH_FREE)
#define HH_gced_p(HEADER) (HEADER & HH_FREE)
#define HH_info(HEADER) ((HEADER & HH_INFO) >> 1)
#define HH_set_space(HEADER,VALUE) HEADER = (VALUE << 5) | (HEADER & ~HH_SPACE)
#define HH_set_free(HEADER,VALUE) HEADER = (HEADER & ~HH_FREE) | (VALUE & HH_FREE)
#define HH_gced(HEADER) HEADER = HEADER | HH_FREE
#define HH_set_info(HEADER,VALUE) HEADER = ((VALUE << 1) & HH_INFO) | (HEADER & ~HH_INFO)
#define HH_set_gcto(HEADER,VALUE) HEADER = (VALUE << 1) | (HEADER & ~HH_GCTO)
#define HH_gc_moved(HEADER,TO) HEADER = (TO << 1) | HH_FREE
#define OA_to_offsets(MPPH) (MPPH)
#define OA_offsets(MPPH) (*MPPH)
#define OA_free(MPPH) (HH_free(heap_memory[*MMPH]))
#define OA_info(MPPH) (HH_info(heap_memory[*MPPH]))
#define OA_space(MPPH) (HH_space(heap_memory[*MPPH]))
#define OA_data(MPPH) (plural char *plural) (heap_memory + (*MPPH) + 1)
#define MPP_2_MPPH(MPPH,MPP) (MPPH = &(plural_memory[MPP]))
#define MPPH_2_MPP(MPP,MPPH) (plural_memory[MPP] = (*MPPH))
/* Original Definitions for future reference */
/* ======== =========== === ====== ========= */
/* extern struct MP_PluralHeap OC_MP_PluralHeap;
* extern struct MP_PluralHeap DOC_MP_PluralHeap;
*
* #ifdef OD_OBJECT_CHECK
*
* #define OA_to_offsets(OBJECT) (error(OBJECT,"OA_to_offsets",OI_MP_PluralHeap)->MP_PluralHeap.to_offsets)
* #define OA_offsets(OBJECT) (*null(error(OBJECT,"OA_offsets",OI_MP_PluralHeap)->MP_PluralHeap.to_offsets))
* #define OA_free(OBJECT) (heap_memory[*null(error(OBJECT,"OA_free",OI_MP_PluralHeap)->MP_PluralHeap.to_offsets)].free)
* #define OA_space(OBJECT) (heap_memory[*null(error(OBJECT,"OA_space",OI_MP_PluralHeap)->MP_PluralHeap.to_offsets)].space)
* #define OA_info(OBJECT) (heap_memory[*null(error(OBJECT,"OA_info",OI_MP_PluralHeap)->MP_PluralHeap.to_offsets)].info)
* #define OA_data(OBJECT) (plural char *plural) (heap_memory + *null(error(OBJECT,"OA_data",OI_MP_PluralHeap)->MP_PluralHeap.to_offsets) + 1)
*
* #else
*
* #define OA_to_offsets(OBJECT) (OBJECT->MP_PluralHeap.to_offsets)
* #define OA_offsets(OBJECT) (*(OBJECT->MP_PluralHeap.to_offset))
* #define OA_free(OBJECT) (heap_memory[*(OBJECT->MP_PluralHeap.to_offsets)].free)
* #define OA_space(OBJECT) (heap_memory[*(OBJECT->MP_PluralHeap.to_offsets)].space)
* #define OA_info(OBJECT) (heap_memory[*(OBJECT->MP_PluralHeap.to_offsets)].info)
* #define OA_data(OBJECT) (plural char *plural)(heap_memory + *(OBJECT->MP_PluralHeap.to_offsets) + 1)
*
* #endif
*
* #define MPP_2_MPPH(MPPH,MPP) (OA_to_offsets(MPPH) = &(plural_memory[OA_offset(MPP)]))
* #define MPPH_2_MPP(MPP,MPPH) (plural_memory[OA_offset(MPP)]=OA_offsets(MPPH))
*
*/